#ifndef _MYGAMEOBJECT_H_
#define _MYGAMEOBJECT_H_

#include "util_complexsprite.h"
#include "util_sheetshader.h"
#include "util_texture.h"

#define DEFAULT_Z_SCALE 1.0f
#define DEFAULT_Z_POS 0.0f

class CMyGameObject
{
public:
	//---------CONSTRUCTORS/DESTRUCTORS---------------------------------------
	CMyGameObject():_obj_shader(NULL),_obj_sprite(NULL)
	{
		setDefaults();
	}
	virtual ~CMyGameObject(){};

	//---------GETTERS AND SETTERS--------------------------------------------
	float getXPos();
	float getYPos();
	float getRotation();
	float getXScale();
	float getYScale();
	int   getCurrentFrame();
	RECT getRect();
	bool  isActive();
	LJMUUtilShaderTexSheet*  getShader();
	LJMUUtilComplexSprite*   getSprite();
	void  setXPos(float px);
	void  setYPos(float py);
	void  setRotation(float pangle);
	void  setXScale(float px);
	void  setYScale(float py);
	void  setActive(bool pactive);
	void  setCurrentFrame(int pframe);
	//void  setRect(float ptop, float pleft, float pbottom, float pright);

	//---------OVERRIDABLE METHODS--------------------------------------------
	virtual bool initialise(LJMUUtilShaderTexSheet* pshader, ID3D10Device* pdevice,std::wstring ptexfilename, int pspritewidth, int pspriteheight,int pnocells);
	virtual bool update(float ptpf);
	virtual bool render(float ptpf,D3DXMATRIX pview, D3DXMATRIX portho);
	virtual bool cleanup();


	//---------PUBLIC METHODS-------------------------------------------------
	float getWidth();
	float getHeight();
	float getHalfWidth();
	float getHalfHeight();
	void  setScale(float pscale);
	void  setRect();
	void  setPosition(float px,float py);
	void  addScale(float pscale);
	void  addPosition(float px,float py);
	void  addRotation(float prot); 
	
	//---------INTERNAL METHODS-----------------------------------------------
protected: 
	void setDefaults();
	float  getFrameUV();

	//---------MEMBER VARIABLES-----------------------------------------------
protected: 
	float					_x_pos;				//X Position of our Sprite
	float					_y_pos;				//Y Position of our Sprite
	float					_angle;				//Angle of our Sprite
	float					_x_scale;			//Scale of our Sprite - X
	float					_y_scale;			//Scale of our Sprite - Y
	bool					_active;			//Whether this object is active or not.
	int						_currentframe;		//Current Animation Frame
	int						_no_frames;			//Maximum Number of Frames
	D3DXMATRIX				_sprite_trans;		//Matrix Representing our Sprite's Position.
	D3DXMATRIX				_sprite_rot;		//Matrix Representing our Sprite's Rotation.
	D3DXMATRIX				_sprite_scale;		//Matrix Representing our Sprite's Scale.
	D3DXMATRIX				_sprite_world;		//Matrix Representing our Sprite's World Matrix.
	D3DXMATRIX				_rect_trans;
	D3DXMATRIX				_rect_rot;
	D3DXMATRIX				_rect_scale;
	D3DXMATRIX				_rect_world;
	LJMUUtilShaderTexSheet*	_obj_shader;		//Shader to Draw our Multiple Objects to Screen.
	LJMUUtilComplexSprite*	_obj_sprite;		//Quad Representing our Sprite Character
	RECT					_rct_shape;
};



/***********************************
*
***********************************/
//inline void CMyGameObject::setRect(float ptop, float pleft, float pbottom, float pright)
//{
//	
//	this->_rct_shape.top = ptop;
//	this->_rct_shape.left = pleft;
//	this->_rct_shape.bottom = pbottom;
//	this->_rct_shape.right = pright;
//}

/***********************************
*
***********************************/
inline RECT CMyGameObject::getRect()
{
	return this->_rct_shape;
}

/***********************************
*
***********************************/
inline float CMyGameObject::getXPos()
{
	return this->_x_pos;
}

/***********************************
*
***********************************/
inline float CMyGameObject::getYPos()
{
	return this->_y_pos;
}

/***********************************
*
***********************************/
inline float CMyGameObject::getRotation()
{
	return this->_angle;
}

/***********************************
*
***********************************/
inline float CMyGameObject::getXScale()
{
	return this->_x_scale;
}

/***********************************
*
***********************************/
inline float CMyGameObject::getYScale()
{
	return this->_y_scale;
}

/***********************************
*
***********************************/
inline bool  CMyGameObject::isActive()
{
	return this->_active;
}

/***********************************
*
***********************************/
inline int CMyGameObject::getCurrentFrame()
{
	return this->_currentframe;
}

/***********************************
*
***********************************/
inline LJMUUtilShaderTexSheet* CMyGameObject::getShader()
{
	return this->_obj_shader;
}

/***********************************
*
***********************************/
inline LJMUUtilComplexSprite* CMyGameObject::getSprite()
{
	return this->_obj_sprite;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setXPos(float px)
{
	this->_x_pos = px;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setYPos(float py)
{
	this->_y_pos = py;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setRotation(float pangle)
{
	this->_angle = pangle;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setXScale(float px)
{
	this->_x_scale = px;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setYScale(float py)
{
	this->_y_scale = py;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setActive(bool pactive)
{
	this->_active = pactive;
}

/***********************************
*
***********************************/
inline void  CMyGameObject::setCurrentFrame(int pframe)
{
	this->_currentframe = pframe;
}

#endif

